class Gun:
    def __init__(self,model):
        self.model=model
        self.bullet_count=0
    def add_bullet(self,count):
        self.bullet_count+=count
    def shoot(self):
        if self.bullet_count==0:
            print('没子弹')
            return
        self.bullet_count-=1
        print(f'发射子弹{self.model}剩余子弹{self.bullet_count}')



class Soldier:
    def __init__(self,name):
        self.name=name
        self.gun=None
    def fire(self):
        if self.gun is None:
            print('没枪')
            return
        self.gun.add_bullet(50)
        self.gun.shoot()

ak47=Gun('ak')
xusanduo=Soldier('许三多')
xusanduo.gun=ak47
xusanduo.fire()